package com.code.day01.JDBCT;

import com.mysql.cj.jdbc.Driver;
import org.junit.Test;

import java.sql.*;

@SuppressWarnings("all")
public class DemoJdbc {
    @Test
    public void insert() throws Exception {
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url = "jdbc:mysql://192.168.254.134:3306/msgcenter";
        String user = "root";
        String password = "esz8311l";
        Connection connection = DriverManager.getConnection(url, user, password);
        System.out.println(connection);
        String sql = "select * from user;";

        Statement statement = connection.createStatement();
        ResultSet resultSet = statement.executeQuery(sql);
        while (resultSet.next()) {
            System.out.println(resultSet.getString("username") + "..." +  resultSet.getInt(2));
        }

        statement.close();
        connection.close();
    }
}
